package com.luhongzhe.tool;

/**
 * @author 	luhongzhe
 * @email  	azhe0660@gmail.com
 * @date   	2011-10-8
 */

public class GravityTool
{
//	s = v0·t + a·t²/2
//	末速度的平方-初速度的平方=2*加速度*路程
	
	private float defaultAcceleration = 0.0001f;
	private float screenHeight;
	
	public GravityTool(float height)
	{
		this.screenHeight = Math.max(height, 300);
	}
	
	public int getCycleTime()
	{
		return (int)Math.sqrt(screenHeight / defaultAcceleration);
	}
	
	public float getOffset(float time)
	{
		return time * time * defaultAcceleration;
	}
}
